package com.administrator.cloudapplication.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.administrator.cloudapplication.models.NewTestModel;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/4/11.
 */

public class NewsAdapter extends FragmentPagerAdapter {
    List<Fragment> mFagmentList;
    ArrayList<NewTestModel.DataBean.CateListBean> mListType = new ArrayList<>();
    public NewsAdapter(FragmentManager fm,ArrayList<NewTestModel.DataBean.CateListBean> ListType,
                       List<Fragment> fragmentLists) {
        super(fm);
        mListType=ListType;
        mFagmentList=fragmentLists;
    }

    @Override
    public Fragment getItem(int position) {
        return mFagmentList.get(position);
    }

    @Override
    public int getCount() {
        return mFagmentList.size();
    }
    //将新闻列表传入适配器，获取到新闻的标题赋给当前页面的TabLayput，这样最上边就有六个标题
    public CharSequence getPageTitle(int position) {
        return mListType.get(position).getCateName();
    }
}
